<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ATM</title>
    <script>
        var monery = 0;  // 金额
        var deposit = 0; // 存入
        var fetch = 0; // 取出
        // var order = prompt("请输入您要的操作：\n 1. 存钱\n 2. 取钱\n 3. 查询余额\n 4. 退出")
        do {
            var order = parseInt(prompt("请输入您要的操作：\n 1. 存钱\n 2. 取钱\n 3. 查询余额\n 4. 退出"));
            /* order == 1 ? (monery += prompt("请输入存入金额：")) :
                (order == 2 ? (monery -= prompt("请输入取出金额：")) :
                    (order == 3 ? alert("查询余额为：" + monery)
                        : alert("结束交易");
                    );
                ); */

            order == 1 ? (monery += prompt("请输入存入金额：")) : (order == 2 ? (monery -= prompt("请输入取出金额：")) : (order == 3 ? alert("查询余额为：" + monery) : (order == 4 ? alert("结束交易") : alert("请输入正确的操作指令！"))));

            // 利用switch...case判断
            /* switch (order) {
                case 1:
                    monery += prompt("请输入存入金额：");
                    continue;
                case 2:
                    monery -= prompt("请输入取出金额：");
                    continue;
                case 3:
                    alert("查询余额为：" + monery);
                    continue;
                case 4:
                    alert("结束交易");
                    continue;
                default:
                    alert("请输入正确的操作指令");
                    continue;
            } */
        } while (order != 4)

    </script>
</head>

<body>

</body>

</html>